package com.colman.osp;

import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;

import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.MapFragment;
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.Marker;
import com.google.android.gms.maps.model.MarkerOptions;

public class MapActivity extends Activity {
	static final LatLng HAMBURG = new LatLng(53.558, 9.927);
	static final LatLng KIEL = new LatLng(53.551, 9.993);
	private GoogleMap mMap;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_map);

		if (mMap == null) {
			mMap = ((MapFragment) getFragmentManager().findFragmentById(
					R.id.map)).getMap();
			// Check if we were successful in obtaining the map.
			if (mMap != null) {

				Marker hamburg = mMap.addMarker(new MarkerOptions().position(
						HAMBURG).title("Hamburg"));
				Marker kiel = mMap.addMarker(new MarkerOptions()
						.position(KIEL)
						.title("Kiel")
						.snippet("Kiel is cool")
						.icon(BitmapDescriptorFactory
								.fromResource(R.drawable.ic_launcher)));

				// Move the camera instantly to hamburg with a zoom of 15.
				mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(HAMBURG, 15));

				// Zoom in, animating the camera.
				mMap.animateCamera(CameraUpdateFactory.zoomTo(10), 2000, null);

			}
		}

	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.map, menu);
		return true;
	}

}
